// 云函数入口文件：getPhoneNumber/index.js
const cloud = require('wx-server-sdk');
cloud.init();

exports.main = async (event) => {
  try {
    console.log(event,"event");
    const { code } = event; // 接收前端传递的code
    const result = await cloud.openapi.phonenumber.getPhoneNumber({
      code: code // 直接传入code
    });
    // 返回手机号信息
    return {
      phoneInfo: result.phoneInfo 
    };
  } catch (err) {
    return { error: err.message };
  }
}